var periodos = {
		init:function(){
			
			var periodo = this;
	
			$('#periodos').jqGrid({
	           url:'periodos/index',
	           datatype:'json',
	           mtype:'POST',
	           colNames:['id','Año','Ciclo','Creado','Estado'],
	           colModel:[
	                {name:"data[Periodo][id]",hidden:true},
	                {name:"data[Periodo][anio]",index:'Periodo.anio',width:100,align:'left',
	            	   sortable:true,editoptions:{maxlength:250, size:30},editable:true,editrules:{required:true},
	            	   searchoptions:{sopt:['cn','eq','ne','lt','le','gt','ge','bw','ew']}
	            	   },
            	   {name:"data[Periodo][ciclo]",index:'Periodo.ciclo',width:100,align:'left',
	            	   sortable:true,editoptions:{maxlength:40, size:15},editable:true,edittype:"select",
	            	   editrules:{required:true},editoptions:{value:"I:I;II:II;III:III;IV:IV;V:V;VI:VI;VII:VII;VIII:VIII;IX:IX;X:X;"},	 
	            	   searchoptions:{sopt:['cn','eq','ne','lt','le','gt','ge','bw','ew']}
		            	   },  
            	   {name:"data[Periodo][created]",index:'Curso.created',width:200,align:'left',sortable:true,editable:false,searchoptions:{sopt:['cn','eq','ne','lt','le','gt','ge','bw','ew']}},
	               {name:"data[Periodo][estado_id]",
				   		index:'Estado.descripcion',
						width:60,
						align:'left',
						editable: true,
						edittype:"select",
						editrules:{required:true},
						editoptions:{
							value:"1:Activo;2:Desactivo"
						},
						searchoptions:{
							sopt:['cn','eq','ne','lt','le','gt','ge','bw','ew']
						}
					}        
	           ],
		
			   pager:$('#periodos-pager'),
	           rowNum:10,
	           rowList:[10,20,30],
	           mtype: "POST",
	           viewrecords:true,
	           caption:'Periodos',
		        rownumbers: true, 
	           height:'230',
	           sortname: "Periodo.id",
	           sortorder: "desc", 
	           editurl: 'periodos/index'         
	                
	       });
			$('#periodos').navGrid("#periodos-pager",{view:true,edit:true,add:true,del:true},
					{clearAfterEdit:false,reloadAfterSubmit:true, bottominfo:"Campos marcados con (*) son requeridos", closeOnEscape:true, afterSubmit:periodo.afterSubmit},
					{clearAfterAdd:true,reloadAfterSubmit:true, bottominfo:"Campos marcados con (*) son requeridos", closeOnEscape:true,afterSubmit:periodo.afterSubmit},
					{width:270,reloadAfterSubmit:true,closeOnEscape:true},
					{sopt:['cn','eq','ne','lt','le','gt','ge','bw','ew'],multipleSearch:true,closeOnEscape:true});	       
			$("#periodo").jqGrid('filterToolbar',{stringResult: true,searchOnEnter : false});
	       jQuery("#periodo").jqGrid('setGridWidth',$('#RightPane').width()-50);
		
		},
		//afterSubmit: function(response){var respuesta = JSON.parse(response.responseText);return [respuesta.respuesta,respuesta.mensaje];}
};
